//
//  ViewController.swift
//  DesignDemo
//
//  Created by luoqiang on 16/3/25.
//  Copyright © 2016年 luoqiang. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let rect = CGRectMake(50, 50, 100, 100)
        let custView = CustomView(frame: rect)
        custView.cornerRadius = 50
        view.addSubview(custView)
        
        
        let custView1 = CustomView()
        custView1.cornerRadius = 50
        custView1.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(custView1)
        
        view.addConstraint(NSLayoutConstraint(item: custView1, attribute: .CenterY, relatedBy: .Equal, toItem: custView, attribute: .CenterY, multiplier: 1, constant: 0))
        view.addConstraint(NSLayoutConstraint(item: custView1, attribute: .Width, relatedBy: .Equal, toItem: custView, attribute: .Width, multiplier: 1, constant: 0))
        view.addConstraint(NSLayoutConstraint(item: custView1, attribute: .Height, relatedBy: .Equal, toItem: custView, attribute: .Height, multiplier: 1, constant: 0))
        view.addConstraint(NSLayoutConstraint(item: custView1, attribute: .Right, relatedBy: .Equal, toItem: view, attribute: .Right, multiplier: 1, constant: -50))
        
        
    }

  


}

